- /* scostrm.cpp by K.Tsuru */
- // function ID = 902
- /**************************
- SComplex class
- It provides the output.
- **************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- // static objects of SComplex class
- int SComplex::scLineFormat = SComplex::BracketFMT; // set by BRACKET | MID_CR| END_CR
- long SComplex::ioCount = 0;
- void SComplex::SetFormat(int fmt) {
- scLineFormat = fmt;
- }
- ostream& operator<<(ostream& os, const SComplex& sc) {
- sc.ioCount = 0;
- SDouble sd;
- long p = 0;
-
- if(sc.scLineFormat & sc.BracketFMT){
- os << '('; p++;
- os << sc.Real(); p += sd.ioCount; sd.ioCount = 0;
- if(sc.scLineFormat & sc.MID_CR) os << ',' << endl; // ",\n" two characters
- else os << ", ";
- p += 2;
-
- os << sc.Imag(); p += sd.ioCount; sd.ioCount = 0;
- os << ')'; p++;
- if(sc.scLineFormat & sc.END_CR) { os << endl; p++; }
- sc.ioCount = p;
- return os;
- }
-
- SDouble im(sc.Imag());
- int imSign = im.Sign(902);
- if(imSign < 0) im.ChangeSign(902); // im = -im > 0
-
- os << sc.Real(); p = sd.ioCount;
-
- if(sc.scLineFormat & sc.MID_CR){ os <<endl; p++; }
- os.flush();
- if(imSign < 0){
- os << "-i*"; p += 3;
- os << im; p += sd.ioCount;
- } else if(imSign > 0){
- os << "+i*"; p += 3;
- os << sc.Imag(); p += sd.ioCount;
- } else {
- os << "+i*0.0"; p += 6;
- }
- if(sc.scLineFormat & sc.END_CR){ os << endl; p++; }
-
- return os;
- }
scostrm.cpp : last modifiled at 2017/06/14 20:43:01(1,388 bytes)
created at 2017/10/06 15:21:28
The creation time of this html file is 2017/10/06 15:27:09 (Fri Oct 06 15:27:09 2017).